<?php
// -----------------------------------------------------------------------------
// include
// -----------------------------------------------------------------------------

include "../config/config.php";
include "../auth.php";
include "../DBManager.php";

// -----------------------------------------------------------------------------

if (!(isset($_POST["id"]) && isset($_POST["title"]))) {
    exit("需要传入有效的参数！");
}

$id = $_POST["id"];
$title = $_POST["title"];
$content = $_POST["content"];

// -----------------------------------------------------------------------------
// 时区设置
// -----------------------------------------------------------------------------

date_default_timezone_set($region);
$timeEdit = (string)time();

// -----------------------------------------------------------------------------
// 数据库相关设置
// -----------------------------------------------------------------------------

$dbPath = "../" . $dbPath; // 不加这行语句的话会报错，提示找不到对应路径
$db = new DBManager("sqlite:" . $dbPath);

// -----------------------------------------------------------------------------
// 访问设置
// -----------------------------------------------------------------------------

if (!$db->storageBoxExist($id)) {
    exit("指定的待办事务收纳箱不存在！");
}

// -----------------------------------------------------------------------------

$arr = [];
$arr["title"] = $title;
$arr["content"] = $content;
$arr["timeEdit"] = $timeEdit;

$db->updateStorageBoxById($id, $arr);

echo "更新成功！";
